﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.BLL;
using Maticsoft.Model;
using FineUI;
namespace EmptyProjectNet45_FineUI
{
    public partial class registry_student : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }



        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            if(tbxUserName.Text==""||tbxPassword.Text==""||tbxPasswordConfirm.Text==""||tbxName.Text=="")
            {
                Alert.ShowInTop("请输入必要信息");
                return;
            }
            if(tbxPassword.Text!=tbxPasswordConfirm.Text)
            {
                Alert.ShowInTop("两次密码不匹配");
                return;
            }
            Maticsoft.BLL.Student CurrentStudent = new Maticsoft.BLL.Student();
            Maticsoft.Model.Student CurrentStuInform = new Maticsoft.Model.Student();
            if (CurrentStudent.Exists(tbxUserName.Text))
            {
                Alert.ShowInTop("您的用户名已经被注册，请重新输入");
                return;
            }
            CurrentStuInform.S_Id = tbxUserName.Text;
            CurrentStuInform.S_Password = tbxPassword.Text;
            CurrentStuInform.S_Name = tbxName.Text;
            CurrentStuInform.S_Sex = tbxSex.Text;
            CurrentStuInform.S_Department = tbxDepartment.Text;
            CurrentStuInform.S_Contact = tbxContact.Text;
            CurrentStuInform.S_Email = tbxEmail.Text;
            CurrentStudent.Add(CurrentStuInform);

            if (CurrentStudent.Exists(tbxUserName.Text))
            {
                Response.Redirect("~/login.aspx");        
            }
            else
            {
                Alert.ShowInTop("注册失败");
            }
        }
    }
}